#include "mysql.h"

//获取单个查询结果
//通过查询语句将查询到的单行单列结果存入字符串
int mysql_select_get_one_str(MYSQL *msql,char *state,char *str){

    MYSQL_RES *res = mysql_get_res(msql, state);
    if(res == (MYSQL_RES*)(-1)){
        return -1;
    }

    if(mysql_num_rows(res) != 1){
        return 0;
    }

    MYSQL_ROW row;
    row = mysql_fetch_row(res);
    strcpy(str, row[0]);

    mysql_free_result(res);
    return 1;
}
